package com.conference.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.conference.service.ConferenceService;
import com.conference.service.ConferenceVenueService;
import java.util.*;

@RestController
@RequestMapping("/api/conferences")
@CrossOrigin(origins = "*", maxAge = 3600)
public class ConferenceStatisticsController {

    @Autowired
    private ConferenceService conferenceService;

    @Autowired
    private ConferenceVenueService venueService;

    @GetMapping("/statistics")
    public ResponseEntity<?> getBasicStatistics() {
        Map<String, Object> statistics = new HashMap<>();
        statistics.put("totalConferences", conferenceService.getTotalConferences());
        statistics.put("publishedConferences", conferenceService.getPublishedConferences());
        statistics.put("upcomingConferences", conferenceService.getUpcomingConferences());
        statistics.put("totalVenues", venueService.getTotalVenues());
        return ResponseEntity.ok(statistics);
    }

    @GetMapping("/status-distribution")
    public ResponseEntity<?> getStatusDistribution() {
        return ResponseEntity.ok(conferenceService.getConferenceStatusDistribution());
    }

    @GetMapping("/venue-usage")
    public ResponseEntity<?> getVenueUsage() {
        return ResponseEntity.ok(conferenceService.getVenueUsageStatistics());
    }

    @GetMapping("/time-distribution")
    public ResponseEntity<?> getTimeDistribution() {
        return ResponseEntity.ok(conferenceService.getMonthlyConferenceCount());
    }
} 